/*Replication file for The Assault on Civil Society: Explaining State Repression of NGOs*/

/*Run on Stata/SE 15.1 for Mac*/

/*Load the dataset*/
use "NGOrepression.dta"


/*Descriptive statistics*/

/*Figure 2 - FINAL*/

ssc install blindschemes, replace all
set scheme plotplainblind, permanently

twoway (line totalreg year if ccode==950) (line totalburdenreg year if ccode==950), ytitle("Number of countries") xtitle("Year") title("NGO Registration Requirements, 1990-2013") legend (label(1 "Registration Required") label(2 "Burdensome Registration"))

/*Figure 3  - FINAL*/


twoway (line totalff year if ccode==950) (line ffbarriers year if ccode==950) (line ffpolacts year if ccode==950), ytitle("Number of countries") xtitle("Year") title("Laws against Foreign Funded NGOs, 1990-2013")  legend (label(1 "Some form of foreign funding restrictions on NGOs") label(2 "Foreign Funding for NGOs fully prohibited") label(3 "Restrictions on political activities by foreign funded NGOs"))

/*Table 2 - FINAL*/


/*Barriers to entry for foreign-funded NGOs*/
list country if q2d==1

/*Prohibitions on foreign funding for NGOs*/
list country if q3e==1|q3e==2|q3f==1|q3f==2

/*Foreign funding must be channeled through govt banks*/
list country if q3c==1

/*Prior govt approval required for foreign funding of NGOs*/
list country if q3b==1

/*Figure 4 - FINAL*/

twoway line totalpolact year if ccode==950, ytitle("Number of countries") xtitle("Year") title("Laws restricting NGO involvement in political activities, 1990-2013")


/*Table 3 - FINAL*/

/*burdensome registration for NGOs*/
tabulate q2b politybinary

/*higher barriers to entry for foreign-funded NGOs*/
tab q2d politybinary

/*Restrictions on foreign funding and support*/
gen foreignfundrestrictions=.
replace foreignfundrestrictions=1 if q3f==1|q3f==2|q3e==1|q3e==2
replace foreignfundrestrictions=0 if missing(foreignfundrestrictions)

tab foreignfundrestrictions politybinary

/*Prohibition of political activities by NGOs*/
tab polact1 politybinary


/*Figure 5 - FINAL*/

gen regimetype=.
replace regimetype=-1 if polity2==-6|polity2==-7|polity2==-8|polity2==-9|polity2==-10  /*autocracy*/
replace regimetype=0 if polity2>-5 & polity2<=5    /*hybrid regime*/
replace regimetype=1 if polity2>=6 & polity2<=10   /*Democracy*/


graph bar (sum) ff, over(regimetype) title("Barriers to Foreign Funding by NGOs by Regime Type, 1990-2013") ytitle("Number of country-years")


/*Figure 6 - FINAL*/

graph bar (sum) polact, over(regimetype) title("Barriers to Political Activities by NGOs by Regime Type, 1990-2013") ytitle("Number of country-years")


/*Analysis*/


/*Table 4 - FINAL*/

logit ff dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagffpercentage PTS_S, robust
logit polact1 dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagq4apercentage PTS_S, robust
zip totaldiss dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_A, inflate(polity2)


/*Table 5 - FINAL*/

/*index of obstruction*/
xtnbreg index dpi_lipc  lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_S, re



/*Figure 7 - FINAL*/
logit ff dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagffpercentage PTS_S, robust
margins, at(dpi_lipc=(0(1)7)) post coeflegend
marginsplot, recast(scatter) xtitle("Legislative Electoral Competitiveness") ytitle("Barriers to Foreign Funding of NGOs") title("Predicted Probabilities with 95% CI") ylabel (0(0.02)0.1) xlabel (,nogrid)

logit ff dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagffpercentage PTS_S, robust
margins, at(dpi_lipc=(0(1)7)) post coeflegend
test _b[1bn._at]=_b[5._at] // Likelihood of adoption of laws, comparing electoral competitiveness at level 0 to level 4
test _b[5bn._at]=_b[8._at] // Likelihood of adoption of laws, comparing electoral competitiveness at level 4 to level 7


/*Figure 8 - FINAL*/

logit polact1 dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagq4apercentage PTS_S, robust
margins, at(dpi_lipc=(0(1)7)) post coeflegend
marginsplot, recast(scatter) xtitle("Legislative Electoral Competitiveness") ytitle("Barriers to Political Activities by NGOs") title("Predicted Probabilities with 95% CI") xlabel (,nogrid)

logit polact1 dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagq4apercentage PTS_S, robust
margins, at(dpi_lipc=(0(1)7)) post coeflegend
test _b[1bn._at]=_b[5._at] // Likelihood of adoption of laws, comparing electoral competitiveness at level 0 to level 4
test _b[5bn._at]=_b[8._at] // Likelihood of adoption of laws, comparing electoral competitiveness at level 4 to level 7


/*Figure 9 - FINAL*/
zip totaldiss dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_A, inflate(polity2)

margins, at(lagprotest=(0(3)37))
marginsplot, recast(scatter) xtitle("Number of Internal Protests") ytitle("Violence Against NGO Activists") xlabel (,nogrid)


graph save Graph "protestsviolence.gph"


margins, at(lagprotest=(0 3 9 15 18 27 37)) post coeflegend

test _b[1bn._at]=_b[2._at] // Number of violent attacks on NGOs and activists, comparing 0 large protests with 3
test _b[2._at]=_b[3._at] // Number of violent attacks on NGOs and activists, comparing 3 large protests with 9
test _b[3._at]=_b[4._at] // Number of violent attacks on NGOs and activists, comparing 9 large protests with 15
test _b[4._at]=_b[5._at] // Number of violent attacks on NGOs and activists, comparing 15 large protests with 18
test _b[5._at]=_b[6._at] // Number of violent attacks on NGOs and activists, comparing 18 large protests with 27
test _b[6._at]=_b[7._at] // Number of violent attacks on NGOs and activists, comparing 27 large protests with 37


logit ff dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagffpercentage PTS_S, robust
margins, at(lagprotest=(0(3)37))
marginsplot, recast(scatter) xtitle("Number of Internal Protests") ytitle("Barriers to Foreign Funding of NGOs") xlabel (,nogrid)

graph save Graph "protestsff.gph"


gr combine "protestsff.gph" "protestsviolence.gph", title("NGOs and Domestic Mobilization")


/*Appendix*/


/*Table 2 - FINAL */
xtlogit ff dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagffpercentage PTS_S, re
xtlogit polact1 dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep lagq4apercentage PTS_S, re
xtpoisson totaldiss dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_S, re




/*Table 3 - FINAL */

xtlogit q2b dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep  PTS_S, re
xtlogit q3c dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep  PTS_S, re
xtlogit q3d dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep  PTS_S, re



/*Table 4: alternative variables to account for reporting bias - FINAL*/ 


zip totaldiss dpi_lipc v2csantimv_osp lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_S, inflate (polity2) robust
ologit vdemcsr dpi_lipc v2csantimv_osp lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_S, robust


/* Table 5: states that use both strategies - FINAL*/

xtlogit both dpi_lipc lagprotest lagpolity e_civil_war  gdp1log logpop lagaiddep PTS_S wbgi_rle, re


/*Table 6: index of obstruction using ols - FINAL*/
reg index dpi_lipc lagprotest lagpolity e_civil_war loggdp logpop lagaiddep lagffpercentage PTS_S

